package com.one.consumer.reserve.ui.binder;

import android.support.annotation.NonNull;
import android.view.View;
import android.widget.ImageView;

import com.one.common.manager.imageloader.ILoader;
import com.one.common.manager.imageloader.LoaderManager;
import com.one.common.view.multitytype.adapter.BaseItemBinder;
import com.one.common.view.multitytype.adapter.BaseViewHolderMulti;
import com.one.consumer.R;
import com.one.consumer.reserve.model.item.AreaItem;

/**
 * author ：zhulunjun
 * email  ：zhulunjun@qq.com
 * date   ：2018/10/30 10:30 PM
 * description ：
 **/
public class AreaBinder extends BaseItemBinder<AreaItem> {
    public AreaBinder(AreaClickListener listener) {
        super(R.layout.item_area);
        this.listener = listener;
    }

    @Override
    protected void bindView(@NonNull BaseViewHolderMulti holder, @NonNull AreaItem item) {
        ImageView imageView = holder.getView(R.id.iv_bg);
        ILoader.Options options = ILoader.Options.roundOptions(8);
        options.setCenterCrop(true);
        options.setBlur(true);
        LoaderManager.getLoader().loadNet(imageView, item.getParts_img(),
                options);
        holder.setText(R.id.tv_name, item.getParts_name());
        holder.getView(R.id.rl_case).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(listener !=null){
                    listener.onAreaClick(item);
                }
            }
        });
    }


    private AreaClickListener listener;

    public interface AreaClickListener{
        void onAreaClick(AreaItem item);
    }


}
